<?php

namespace app\admin\model\orders;

use think\Model;


class Lists extends Model
{

    

    // 表名
    protected $table = 'orders';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text',
        'pay_style_text'
    ];

    public function getorderinfo(){
        return $this->belongsTo('app\admin\model\Orderinfo','order_id','id',[],'LEFT')->setEagerlyType(0);
    }
    
    public function getStatusList()
    {
        return ['1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4'), '5' => __('Status 5')];
    }

    public function getPayStyleList()
    {
        return ['1' => __('Pay_style 1'), '2' => __('Pay_style 2'), '3' => __('Pay_style 3')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPayStyleTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['pay_style']) ? $data['pay_style'] : '');
        $list = $this->getPayStyleList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
